/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.zonasoft.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author JORGE
 */
@Entity
@Table(name = "zona", catalog = "zonificacion", schema = "")
@NamedQueries({
    @NamedQuery(name = "Zona.findAll", query = "SELECT z FROM Zona z"),
    @NamedQuery(name = "Zona.findByIdzona", query = "SELECT z FROM Zona z WHERE z.idzona = :idzona"),
    @NamedQuery(name = "Zona.findByCodigo", query = "SELECT z FROM Zona z WHERE z.codigo = :codigo")})
public class Zona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idzona", nullable = false)
    private Long idzona;
    @Basic(optional = false)
    @Column(name = "codigo", nullable = false, length = 6)
    private String codigo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idzona")
    private List<Puestodevotacion> puestodevotacionList;
    @JoinColumn(name = "idmunicipio", referencedColumnName = "codigo", nullable = false)
    @ManyToOne(optional = false)
    private Municipios idmunicipio;

    public Zona() {
    }

    public Zona(Long idzona) {
        this.idzona = idzona;
    }

    public Zona(Long idzona, String codigo) {
        this.idzona = idzona;
        this.codigo = codigo;
    }

    public Long getIdzona() {
        return idzona;
    }

    public void setIdzona(Long idzona) {
        this.idzona = idzona;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public List<Puestodevotacion> getPuestodevotacionList() {
        return puestodevotacionList;
    }

    public void setPuestodevotacionList(List<Puestodevotacion> puestodevotacionList) {
        this.puestodevotacionList = puestodevotacionList;
    }

    public Municipios getIdmunicipio() {
        return idmunicipio;
    }

    public void setIdmunicipio(Municipios idmunicipio) {
        this.idmunicipio = idmunicipio;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idzona != null ? idzona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Zona)) {
            return false;
        }
        Zona other = (Zona) object;
        if ((this.idzona == null && other.idzona != null) || (this.idzona != null && !this.idzona.equals(other.idzona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.zonasoft.enridades.Zona[idzona=" + idzona + "]";
    }

}
